/**
 * SinglePageTemplate abstract
 * @author konblueskly
 * @date 2018-10-09
 * @ref http://asciiflow.com/
 *
 * usage
 * 1. import
 * 2. use it in mixins
 * 3. set container ref name in "sp_tpl.ref"
 *
 *
 * todo:
 * 单页面公共方法,search区域公共操作
 *
 *
 * SinglePage
 *
 * +-----CardContainer------------------------------------------------+
 * | +--------------------------------------------------------------+ |
 * | |                                                              | |
 * | |     This area for search                                     | |
 * | |                                                              | |
 * | +--------------------------------------------------------------+ |
 * | +--------------------------------------------------------------+ |
 * | |     header of table                                          | |
 * | |                                                              | |
 * | +--------------------------------------------------------------+ |
 * | |                                                              | |
 * | |                                                              | |
 * | |                                                              | |
 * | |     body                                                     | |
 * | |                                                              | |
 * | |                                                              | |
 * | |                                                              | |
 * | +--------------------------------------------------------------+ |
 * | |      footer                                                  | |
 * | |                                                              | |
 * | +--------------------------------------------------------------+ |
 * +------------------------------------------------------------------+
 *
 */

import PageProvider from './PageProvider.js';
export default {
  mixins:[PageProvider],
  data () {
    return {
      sp_tpl: {
        //容器的name
        ref: ''
      }
    };
  },
  methods:{
    //@Override
    changeSize (size) {
      this.page.pageSize = size;
      this.initValue();
      //调整分页后,容器需要重新计算高度
      if(this.sp_tpl.ref){
        let containerRefEl=this.$refs[this.sp_tpl.ref].$el.style.height="100%";
      }
    }
  },
  /**
   * 动态计算容器高度
   */
  mounted () {
    // 根据ref中的容器名 取得容器dom节点
    if(this.sp_tpl.ref){
      let containerRefEl=this.$refs[this.sp_tpl.ref].$el;
      if(containerRefEl){
        let height=(window.innerHeight - containerRefEl.offsetTop - 120) + 'px'
        // 操作dom赋值
        containerRefEl.style.height=height;
      }
    }
    // 计算高度
  }
};
